<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>下载登录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/css/login.css" media="all">
    <style type="text/css">
        body {
            background: #62073D;
        }

        .login-panel {
            position: absolute;
            left: 50%;
            top: 50%;
            margin-left: -227px;
            margin-top: -210px;
        }
    </style>
</head>

<body class="layui-layout-body">
<div class="login-panel">
    <div class="title-section">
        <h1>下载系统</h1>
        <span>请输入账号密码</span>
        <i class="layui-icon layui-icon-password i-icon"></i>
    </div>
    <div class="input-section">
        <form role="form" class="layui-form login-form" action="/loginDo" method="post">
            <input type="text" name="name" lay-verify="required" value="" placeholder="用户名" autocomplete="on"
                   class="layui-input">
            <input type="password" name="pwd" lay-verify="required" value="" placeholder="密码" autocomplete="on"
                   class="layui-input">
            <div class="layui-form-item" style="margin-bottom: 20px;">
                <input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>记住密码</span><i
                            class="layui-icon layui-icon-ok"></i></div>
            </div>
            <button class="layui-btn layui-btn-fluid layui-bg-red" lay-submit lay-filter="*">登录</button>
        </form>
    </div>
</div>
<div class="layui-footer">
</div>
<script src="/static/layui/layui.js" type="text/javascript"></script>
<script>
    var loginHtml = ''
    layui.use(['element', 'layer', 'form'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            form = layui.form;
        var loginingFlag = false;

        // 通用表单提交(AJAX方式)
        form.on('submit(*)', function (data) {
            if (!loginingFlag) {
                loginingFlag = true;
                $.ajax({
                    url: data.form.action,
                    type: data.form.method,
                    data: $(data.form).serialize(),
                    success: function (info) {
                        // console.log(info);
                        if (info.code == 0) {
                            layer.msg(info.msg);
                            window.location.href = info.url;

                        } else {
                            layer.msg(info.msg, {
                                icon: 5
                            })
                        }

                        loginingFlag = false;
                    },
                    error: function (msg) {
                        loginingFlag = false;
                        var json = JSON.parse(msg.responseText);
                        $.each(json.errors, function (idx, obj) {
                            layer.msg(obj[0]);
                            return false;
                        });
                    }
                });
            }
            return false;
        });
    });
</script>
</body>
</html>
